/*
 * EZCP_Sim_Common.c
 *
 *  Created on: Mar 27, 2011
 *      Author: Group 8
 */
#include "EZCP_Sim_Common.h"

static int cfgDebugLevel = EZ_D;

void ConfigureDebugLevel (int level)
{
	cfgDebugLevel = level;
	return;
}

void MSG_PRINT( int DebugLevel, const char* format, ... )
{
	s32 si_ErrFlag;
    va_list args;
    si_ErrFlag = 0;

    if (DebugLevel > cfgDebugLevel)
    	return;

    switch (DebugLevel)
    {
		case EZ_E:
			fprintf( stderr, "ERROR:   " );
			break;
		case EZ_W:
			fprintf( stderr, "WARNING: " );
			break;
		case EZ_I:
			fprintf( stderr, "INFO:    " );
			break;
		case EZ_D:
			//fprintf( stderr, "DEBUG:   %s:%d:%s():",  __FILE__, __LINE__, __func__);
			fprintf( stderr, "DEBUG:   " );
			break;
		default:
			si_ErrFlag = 1;
			break;
    }
    if (si_ErrFlag)
    {
    	fprintf( stderr, "Wrong usage of MSG_PRINT, please specify correct Debug Level.\n\n" );
    }
    else
    {
    	va_start( args, format );
		vfprintf( stderr, format, args );
		va_end( args );
		fprintf( stderr, "\n" );
    }

    return;
}
